﻿@model TalentDesk.Contracts.Ef.Project
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Globalize.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/globalize.culture.tr-TR.js")" type="text/javascript"></script>

@using (Ajax.BeginForm("ProjectKaydet", "Project", new AjaxOptions { HttpMethod ="Post" , UpdateTargetId = "divsonuc" }))
{
  
    <table>
        <tr>
            <td>@Html.LabelFor(p => p.ProjectName)</td>
            <td>@Html.TextBoxFor(p => p.ProjectName, new { @class = "k-textbox" })</td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td>@Html.LabelFor(p => p.ProjectType)</td>
            <td>@(Html.Kendo().DropDownListFor(p => p.ProjectTypeId)

              .HtmlAttributes(new { style = "width:300px" })
              .OptionLabel("Select projecttype...")
              .DataTextField("ProjectType1")
              .DataValueField("ProjectTypeId")
              .DataSource(source =>
              {
                  source.Read(read =>
                  {
                      read.Action("GetProjectTypes", "CacheEnum");
                  });
              })
        )</td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td>@Html.LabelFor(p => p.Progress)</td>
            <td>@(Html.Kendo().SliderFor(p => p.Progress)
          .Name("slider")
          .Min(0)
          .Max(100)
          .SmallStep(1)
          .LargeStep(10)
          .HtmlAttributes(new { @class = "eqSlider" })
          )</td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td>@Html.LabelFor(p => p.ProjectTeams)</td>
            <td colspan="3">@(Html.Kendo().MultiSelectFor(model => model.ProjectTeams)
                              .Placeholder("Select Countires")
                              .DataTextField("FirstName")
                              .DataValueField("UserId")
                              .Filter(FilterType.Contains)
                              .BindTo(TalentDesk.Mvc.Models.AuthenticationProxy.GetUser())
                              .Height(300)
                              .ItemTemplate("<img src=\"" + Url.Content("~\\Images\\User\\") + "#:data.ImageUrl# \" alt=\"#:data.UserId#\" />" +
                                            "<h3>#: data.FirstName #  #: data.LastName #</h3>")
                              .TagTemplate("<img class=\"tag-image\" src=\"" + Url.Content("~\\Images\\User\\") + "#:data.ImageUrl# \" alt=\"#:data.UserId#\" />" +
                                          "#: data.FirstName #  #: data.LastName #")
                   )</td>
        </tr>
        <tr>
            <td>@Html.LabelFor(p => p.StartDate)</td>
            <td>@Html.Kendo().DatePickerFor(p => p.StartDate)</td>
            <td>@Html.LabelFor(p => p.DueDate)</td>
            <td>@Html.Kendo().DatePickerFor(p => p.DueDate)</td>
        </tr>
        <tr>
            <td>@Html.LabelFor(p => p.ProjectDescription)</td>
            <td colspan="3">@Html.TextBoxFor(p => p.ProjectDescription, new { @class = "k-textbox" })       </td>
        </tr>
        <tr>
            <td>Files</td>
            <td>@(Html.Kendo().Upload()
                            .Name("files")
                             .Multiple(false)
                         )</td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td>Files</td>
            <td colspan="3">@(Html.Kendo().Grid(Model.Attachments)
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.FileName);
        columns.Bound(p => p.CreateTime).ClientTemplate("#= productDetails(data) #");
    })
    .Pageable()
    .Sortable()
    .Selectable()
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .ServerOperation(false)
        .Model(model => model.Id(c => c.AttachmentId))

     )
)</td>
        </tr>
        <tr>
            <td colspan="4">
                <input type="submit" value="Save">
                <input type="button" value="Cancel" onclick="ModalCancel()">
        </tr>
    </table>
           
               

   
        
    @Html.HiddenFor(p => p.ProjectId)
}

<script>
    function productDetails(product) {
        var action = '@Url.Action("DownloadFile", "Project")';

        var html = kendo.format("<a href='{0}/{1}'>Download</a>",
            action,
            product.AttachmentId
        );

        return html;
    }
</script>

